﻿@{
    Layout = "~/Shared/Layouts/_AdminLayout.cshtml";
    Page.Title = "Производи";

    var db = Database.Open("VirtualeShop");
    var sqlCommand = "SELECT Products.ProductId, Products.Title, Categories.CategoryTitle " +
                     "FROM Products " + 
                     "INNER JOIN Categories ON Products.Category = Categories.CategoryId " +
                     "ORDER BY title";

    var result = db.Query(sqlCommand);
                    
    var productsGrid = new WebGrid(source: result,
                                    rowsPerPage: 20);

}

<h1>Преглед на производи</h1>
<a href="ProductDetails">Додади нов производ</a>
<div class="grid">
    @productsGrid.GetHtml(
        tableStyle: "grid",
        headerStyle: "gridHeader",
        alternatingRowStyle: "gridAlt",
        footerStyle: "gridFooter",
        columns: productsGrid.Columns(
            productsGrid.Column("ProductId",
                              "Број на Производ"),
            productsGrid.Column("Title",
                              "Наслов на Производ"),
            productsGrid.Column("CategoryTitle",
                              "Категорија"),
            productsGrid.Column(null,
                              null,
                              format: @<text>
                                          <a href="ProductDetails/@item.ProductId">
                                              Повеќе...
                                          </a>
                                      </text>)
        )
    )
</div>
